/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoLockTest.go			*/
/********************************************************/

package main

import (
	"runtime"
	. "GoGlb"
	C "GoCls"
)

var count int = 0

func main() {
	j := 20
	var l C.GoLock
	l.GoLockInit()
	for i := 0; i < j; i ++ {
		go test(l)
	}
	for {
		l.GoLockLock()
		CntTmp := count
		l.GoLockUnlock()
		runtime.Gosched()
		if CntTmp >= j {
			break
		}
	}
}

func test(l C.GoLock) {
	l.GoLockLock()
	count += 1
	GoPrint("Count: %04d\n", count)
	l.GoLockUnlock()
}
